package com.newlink.building.record.adapter

import android.widget.CheckBox
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.newlink.building.record.R
import com.newlink.building.record.bean.Module_Record_RecordDeviceDialogBean

/**
 * @author wangyang
 * @date 2022/10/19
 * @description 记录——选择设备的dialog的Adapter
 */
class Module_Record_RecordDeviceDialogAdapter(data: MutableList<Module_Record_RecordDeviceDialogBean>) :
    BaseQuickAdapter<Module_Record_RecordDeviceDialogBean, BaseViewHolder>(
        R.layout.item_record_device_dialog,
        data
    ) {

    init {
        addChildClickViewIds(R.id.area_container)
    }

    override fun convert(holder: BaseViewHolder, item: Module_Record_RecordDeviceDialogBean) {
        holder.setText(R.id.tv_content, item.device)
        val checkBox = holder.getView<CheckBox>(R.id.cb_select)
        checkBox.isChecked = item.isChecked

        if (item.isChecked) {
            holder.setTextColor(R.id.tv_content, context.getColor(R.color.default_red))
        } else {
            holder.setTextColor(R.id.tv_content, context.getColor(R.color.default_text))
        }
    }
}